<%@ include file = "/js/_of_js.jsp"%>
<script type="text/javascript" src="/FCKeditor/fckeditor.js"></script>
<script>
    function validate()
    {
        var isPassed = true;
//        // 知识分类
//        $('knowledgeTypeId_error').innerHTML = "";    
//        if($F('knowledgeTypeId') == null)
//        {
//            $('knowledgeTypeId_error').innerHTML = "<font color='red' style='font:bold'>无此科目的知识分类</font>";
//            isPassed = false;
//        }
        // 标题
        $('title_error').innerHTML = "";
        if($F('title').length == 0)
        {
            $('title_error').innerHTML = "<font color='red' style='font:bold'>必填</font>";
            isPassed = false;
        }
        if($F('title').length >1500)
        {
            $('title_error').innerHTML = "<font color='red' style='font:bold'>过长</font>";
            isPassed = false;
        }
        // 知识点
        $('knowledgePointId_error').innerHTML = "";    
        if($F('knowledgePointId') == null)
        {
            $('knowledgePointId_error').innerHTML = "<font color='red' style='font:bold'>必填</font>";
            isPassed = false;
        }
        // 主编
        $('authorName_error').innerHTML = "";          
        if($F('authorName').length == 0)
        {
            $('authorName_error').innerHTML = "<font color='red' style='font:bold'>必填</font>";
            isPassed = false;
        }
        if($F('authorName').length > 10)
        {
            $('authorName_error').innerHTML = "<font color='red' style='font:bold'>长度超过10</font>";
            isPassed = false;
        }
        // 提交按钮
        $('submitButton').disabled = !isPassed;
    }

    function goback()
    {
        window.location.href = "<%= request.getContextPath()%>/moduleinfor/back2LastList.jsp";
    }
    
    function reset()
    {
        
        <%        
        // 域
        Object[] domains = typeManager.getByCode("domain").getSubTypes().toArray();
        for(int i = 0; i < domains.length; i ++)
        {
            Type domain = (Type)domains[i];
            %>addOption(detailForm.domainId,"<%= domain.getId()%>","<%= domain.getName()%>");<%
        }

        // 难度
        Object[] difficultys = typeManager.getByCode("difficulty").getSubTypes().toArray();
        for(int i = 0; i < difficultys.length; i ++)
        {
            Type difficulty = (Type)difficultys[i];
            %>addOption(detailForm.difficultyId,"<%= difficulty.getId()%>","<%= difficulty.getName()%>");<%
        }

        // 出版社
        Object[] publishCompanys = typeManager.getByCode("Press").getSubTypes().toArray();
        for(int i = 0; i < publishCompanys.length; i ++)
        {
            Type publishCompany = (Type)publishCompanys[i];
            %>addOption(detailForm.publishCompanyId,"<%= publishCompany.getId()%>","<%= publishCompany.getName()%>");<%
        }
        %>
        if(domainId != null)
        {
            $('domainId').value = domainId;
            domainId = null;
        }
    }
    function bodyLoadJS()
    {
        // 被聚焦的控件
        detailForm.domainId.focus(); 
    }
</script>
    <form id="detailForm" name="detailForm" action="<%= request.getContextPath()%>/moduleinfor/Controller.jsp" method="post" >
        <tr>
            <td class="detailTD11">领域&nbsp;&nbsp;</td>
            <td class="detailTD12">
                <select id="domainId" name="domainId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true">					
				</select>
            </td>
            <script type="text/javascript">
                new Form.Element.Observer('domainId', 1, 
                        function(element, value) 
                        {                               
                            new Ajax.Updater('initSubjectJs', 
                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/ajax/findBySuperTypeId.jsp', 
                                {asynchronous:true, evalScripts:true, parameters:'objId=subjectId&value='+value});
                         })
            </script>
			<td class="detailTD11">学科&nbsp;&nbsp;</td>
            <td class="detailTD12">                
                <select id="subjectId" name="subjectId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true"></select>
                <span id="initSubjectJs"></span>
            </td>
            <script type="text/javascript">
                new Form.Element.Observer('subjectId', 1, 
                        function(element, value) 
                        { 
                            if(checkOptionValue($('subjectId'),subjectId))
                            {
                                $('subjectId').value = subjectId;
                                subjectId = null;
                            }
                            new Ajax.Updater('initCourseJs', 
                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/ajax/findBySuperTypeId.jsp', 
                                {asynchronous:true, evalScripts:true, parameters:'objId=courseId&value='+value})
                        })
            </script>
			<td class="detailTD11">课程&nbsp;&nbsp;</td>
            <td class="detailTD12">
                <select id="courseId" name="courseId" onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true"></select>
                <span id="initCourseJs"></span>
            </td>
            <script type="text/javascript">
                new Form.Element.Observer('courseId', 1, 
                        function(element, value) 
                        { 
                            if(checkOptionValue($('courseId'),courseId))
                            {
                                $('courseId').value = courseId;
                                courseId = null;
                            }
                            new Ajax.Updater('initUnitJs', 
                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/ajax/findBySuperTypeId.jsp', 
                                {asynchronous:true, evalScripts:true, parameters:'objId=unitId&value='+value});
//                            new Ajax.Updater('initknowledgeTypeJs', 
//                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/knowledgeType/findBySubjectId4ajax.jsp', 
//                                {asynchronous:true, evalScripts:true, parameters:'objId=knowledgeTypeId&value='+value});
                        })
            </script>
        </tr>
        <tr >
            
			<td class="detailTD21">章&nbsp;&nbsp;</td>
            <td class="detailTD22">
                <select name="unitId" onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true"></select>
                <span id="initUnitJs"></span>
            </td>
            <script type="text/javascript">
                new Form.Element.Observer('unitId', 1, 
                        function(element, value) 
                        { 
                            if(checkOptionValue($('unitId'),unitId))
                            {
                                $('unitId').value = unitId;
                                unitId = null;
                            }
                            new Ajax.Updater('initSectionJs', 
                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/ajax/findBySuperTypeId.jsp', 
                                {asynchronous:true, evalScripts:true, parameters:'objId=sectionId&value='+value})
                        })
            </script>
			<td class="detailTD21">节&nbsp;&nbsp;</td>
            <td class="detailTD22">
                <select name="sectionId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true">
				</select><span id="initSectionJs"></span>
            </td>
            <script type="text/javascript">
                new Form.Element.Observer('sectionId', 1, 
                        function(element, value) 
                        {   
                            if(checkOptionValue($('sectionId'),sectionId))
                            {
                                $('sectionId').value = sectionId;
                                sectionId = null;
                            }
                            new Ajax.Updater('initKnowledgePointJs', 
                                '<%= request.getContextPath()%>/moduleinfor/basedata/type/ajax/findBySuperTypeId.jsp', 
                                {asynchronous:true, evalScripts:true, parameters:'objId=knowledgePointId&value='+value})
                        })
            </script>
			<td  class="detailTD21">知识点&nbsp;&nbsp;</td>
            <td class="detailTD22">
                <select id="knowledgePointId" name="knowledgePointId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true">
				</select>&nbsp;&nbsp;<span id="knowledgePointId_error"></span>
                <span id="initKnowledgePointJs"></span>
            </td>
            <script type="text/javascript">
                new Form.Element.Observer('knowledgePointId', 1, 
                        function(element, value) 
                        {          
                            if(checkOptionValue($('knowledgePointId'),knowledgePointId))
                            {
                                $('knowledgePointId').value = knowledgePointId;
                                knowledgePointId = null;
                            }
                        })
            </script>
        </tr>
         <tr>
            <td class="detailTD11">难度&nbsp;&nbsp;</td>
            <td class="detailTD12" >
                <select name="difficultyId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true">					
				</select>
            </td>  
<!-- 			<td class="detailTD11">知识分类&nbsp;&nbsp;</td>
            <td class="detailTD12" >
                <select name="knowledgeTypeId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true">					
				</select>&nbsp;&nbsp;<span id="knowledgeTypeId_error"></span><span id="initknowledgeTypeJs"></span>
            </td> -->
            <script type="text/javascript">
//                new Form.Element.Observer('knowledgeTypeId', 1, 
//                        function(element, value) 
//                        {          
//                            if(checkOptionValue($('knowledgeTypeId'),knowledgeTypeId))
//                            {
//                                $('knowledgeTypeId').value = knowledgeTypeId;
//                                knowledgeTypeId = null;
//                            }
//                        })
            </script>            
            <td class="detailTD11">出版社&nbsp;&nbsp;</td>
            <td class="detailTD12">
                <select name="publishCompanyId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true">
            </td>
            <td class="detailTD11">主编&nbsp;&nbsp;</td>
            <td class="detailTD12" >
                <input type="text" name="authorName" value="<%= authorName%>" >&nbsp;&nbsp;<span id="authorName_error"></span>
            </td>
		</tr>
        <tr>
            <td class="detailTD21">标题&nbsp;&nbsp;</td>
            <td class="detailTD22" colspan="5">
                <input type="text" id="title" name="title" value="<%= trTitle%>"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true" size="100">
                &nbsp;&nbsp;<span id="title_error"></span>
            </td>  
        </tr>
        <script>
            function changeFck(obj)
            {
                for(var i = 0; i < 8; i ++)
                {
                    eval("$('fck" + i + "').style.fontWeight = '';");
                    eval("$('fck" + i + "inst').style.display = 'none';");
                }
                obj.style.fontWeight = "bold";
                eval("$('" + obj.id + "inst').style.display = '';");
            }
        </script>
        <tr>
            <td class="detailTD11" title="点击切换" align="right">
                <table width="80">
                    <tr>
                        <td id="fck0" style="cursor:hand;font:bold" onclick = "changeFck(this)">标准&nbsp;&nbsp;</td>
                    </tr>
                    <tr>
                        <td id="fck1" style="cursor:hand" onclick = "changeFck(this)">电子课文&nbsp;&nbsp;</td>
                    </tr>
                    <tr>
                        <td id="fck2" style="cursor:hand" onclick = "changeFck(this)">经典例题&nbsp;&nbsp;</td>
                    </tr>
                    <tr>
                        <td id="fck3" style="cursor:hand" onclick = "changeFck(this)">教学设计&nbsp;&nbsp;</td>
                    </tr>
                    <tr>
                        <td id="fck4" style="cursor:hand" onclick = "changeFck(this)">精美课件&nbsp;&nbsp;</td>
                    </tr>
                    <tr>
                        <td id="fck5" style="cursor:hand" onclick = "changeFck(this)">视频动画&nbsp;&nbsp;</td>
                    </tr>
                    <tr>
                        <td id="fck6" style="cursor:hand" onclick = "changeFck(this)">背景资料&nbsp;&nbsp;</td>
                    </tr>
                    <tr>
                        <td id="fck7" style="cursor:hand" onclick = "changeFck(this)">百家争鸣&nbsp;&nbsp;</td>
                    </tr>
                </table>
            </td>
            <td class="detailTD12" colspan="5">
                <table width="100%">
                    <tr id="fck0inst" style="display:">
                        <td >
                            <%
                            FCKeditor oFCKeditor = new FCKeditor( request, "standard" ) ;
                            oFCKeditor.setBasePath( "/FCKeditor/" ) ;
                            oFCKeditor.setValue(standard);
                            oFCKeditor.setHeight("270");
                            out.println( oFCKeditor.create() ) ;
                            %>
                        </td>
                    </tr>
                    <tr id="fck1inst" style="display:none">
                        <td >
                            <%
                            oFCKeditor = new FCKeditor( request, "elecText" ) ;
                            oFCKeditor.setBasePath( "/FCKeditor/" ) ;
                            oFCKeditor.setValue(elecText);
                            oFCKeditor.setHeight("270");
                            out.println( oFCKeditor.create() ) ;
                            %>
                        </td>
                    </tr>
                    <tr id="fck2inst" style="display:none">
                        <td >
                            <%
                            oFCKeditor = new FCKeditor( request, "classicQuest" ) ;
                            oFCKeditor.setBasePath( "/FCKeditor/" ) ;
                            oFCKeditor.setValue(classicQuest);
                            oFCKeditor.setHeight("270");
                            out.println( oFCKeditor.create() ) ;
                            %>
                        </td>
                    </tr>
                    <tr id="fck3inst" style="display:none">
                        <td >
                            <%
                            oFCKeditor = new FCKeditor( request, "teachDesign" ) ;
                            oFCKeditor.setBasePath( "/FCKeditor/" ) ;
                            oFCKeditor.setValue(teachDesign);
                            oFCKeditor.setHeight("270");
                            out.println( oFCKeditor.create() ) ;
                            %>
                        </td>
                    </tr>
                    <tr id="fck4inst" style="display:none">
                        <td >
                            <%
                            oFCKeditor = new FCKeditor( request, "courseWare" ) ;
                            oFCKeditor.setBasePath( "/FCKeditor/" ) ;
                            oFCKeditor.setValue(courseWare);
                            oFCKeditor.setHeight("270");
                            out.println( oFCKeditor.create() ) ;
                            %>
                        </td>
                    </tr>
                    <tr id="fck5inst" style="display:none">
                        <td >
                            <%
                            oFCKeditor = new FCKeditor( request, "video" ) ;
                            oFCKeditor.setBasePath( "/FCKeditor/" ) ;
                            oFCKeditor.setValue(video);
                            oFCKeditor.setHeight("270");
                            out.println( oFCKeditor.create() ) ;
                            %>
                        </td>
                    </tr>
                    <tr id="fck6inst" style="display:none">
                        <td >
                            <%
                            oFCKeditor = new FCKeditor( request, "backGround" ) ;
                            oFCKeditor.setBasePath( "/FCKeditor/" ) ;
                            oFCKeditor.setValue(backGround);
                            oFCKeditor.setHeight("270");
                            out.println( oFCKeditor.create() ) ;
                            %>
                        </td>
                    </tr>
                    <tr id="fck7inst" style="display:none">
                        <td >
                            <%
                            oFCKeditor = new FCKeditor( request, "others" ) ;
                            oFCKeditor.setBasePath( "/FCKeditor/" ) ;
                            oFCKeditor.setValue(others);
                            oFCKeditor.setHeight("270");
                            out.println( oFCKeditor.create() ) ;
                            %>
                        </td>
                    </tr>
                </table>				
            </td>
		</tr>
         <input type="hidden" id="id" name="id" value="<%= trId%>">
          <input type="hidden" name="serviceURL">
    </form>
    <script>
        new Form.Observer('detailForm',
                          1,
                          function (element,value)
                          {
                              validate();
                          });
    </script>